<?php

$link =  mysqli_connect("localhost","root","root","2116");
// echo 1111;
// print_r($_POST);
// print_r($_FILES);
// 先把文件转存到指定目录
$temUrl = $_FILES['img']['tmp_name'];
$name = $_FILES['img']['name'];
move_uploaded_file($temUrl,"./uploads/".$name);

$title = $_POST['title'];
$content = $_POST['content'];
$type = $_POST['type'];
$country = $_POST['country'];
$imgurl = "./uploads/".$name;

$sql = "INSERT INTO news(title,content,type,country,imgurl) VALUES('$title','$content','$type','$country','$imgurl')";
mysqli_query($link,$sql);
if(mysqli_affected_rows($link)){
	$arr['info'] = "添加成功";
	$arr['status'] = 1;
}else{
	$arr['info'] = "添加失败";
	$arr['status'] = 0;
}

echo json_encode($arr);




?>